package com.mobilekites.ga;

import android.app.Activity;
import android.content.Context;

import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.MapBuilder;

public interface GoogleAnalytics {
	public void sentEventCategory(String category);

	public void sentEventSubCategory(String category, String subCategory);

	public void sentEventDownload();

	public static final class GoogleAnalyticsImpl implements GoogleAnalytics {
		public EasyTracker mEasyTracker;
		private Context mContext;

		public GoogleAnalyticsImpl(Context context) {
			mEasyTracker = EasyTracker.getInstance(context);
			mContext = context;
		}

		public void onStart(Activity activity) {
			mEasyTracker.activityStart(activity);
		}

		public void onStop(Activity activity) {
			mEasyTracker.activityStop(activity);
		}

		public void onDestroy() {
			mContext = null;
			mEasyTracker = null;
		}

		@Override
		public void sentEventCategory(String category) {
			mEasyTracker = EasyTracker.getInstance(mContext);
			mEasyTracker.send(MapBuilder.createEvent("Android", category, null,
					0L).build());
		}

		@Override
		public void sentEventDownload() {
			mEasyTracker = EasyTracker.getInstance(mContext);
			mEasyTracker.send(MapBuilder.createEvent("Android", "download",
					null, 0L).build());
		}

		@Override
		public void sentEventSubCategory(String category, String subCategory) {
			mEasyTracker = EasyTracker.getInstance(mContext);
			mEasyTracker.send(MapBuilder.createEvent("Android", category,
					subCategory, 0L).build());
		}

	}
}
